package com.hspedu.newData.dmsxl.链表.删除;

import com.hspedu.newData.dmsxl.ds.ListNode;
import org.junit.Test;


/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-04-27 
 * @Version: 1.0
 */

public class LC83删除排序链表中的重复元素 {

    public ListNode deleteDuplicates(ListNode head) {

        ListNode cur = head;

        while(cur != null && cur.next != null){
            if (cur.val == cur.next.val){
                cur.next = cur.next.next;
                continue;
            }
            cur = cur.next;
        }

        return head;
    }

    @Test
    public void test() {
        // 测试代码
        ListNode l1 = new ListNode(4, null);
        ListNode l2 = new ListNode(4, l1);
        ListNode l3 = new ListNode(1, l2);
        ListNode l4 = new ListNode(1, l3);
        ListNode l5 = new ListNode(1, l4);
        ListNode l6 = new ListNode(1, l5);

        ListNode listNode = deleteDuplicates(l6);

        System.out.println("111");
    }

}
